package com.hdoit.ares.selfcommon.utils;

import java.util.Date;

import org.springframework.util.StringUtils;

import com.hdoit.ares.logical.policy.model.ListPolicy;

public class PolicyInsuStateUtil {

	public static void changeState(ListPolicy listPolicy) {

		Date statetime = listPolicy.getStartDate();
		Date endtime = listPolicy.getEndDate();
		Date nowtime = new Date();

		long statetimeLong = statetime.getTime();
		long endtimeLong = endtime.getTime();
		long nowtimeLong = nowtime.getTime();
		if (StringUtils.isEmpty(listPolicy.getOid())) {
			listPolicy.setInsuState("fail");
		} else {
			if (nowtimeLong < statetimeLong) {
				listPolicy.setInsuState("ready");
			}
			if (nowtimeLong > statetimeLong && nowtimeLong < endtimeLong) {
				listPolicy.setInsuState("yes");
			}
			if (nowtimeLong > endtimeLong) {
				listPolicy.setInsuState("no");
			}
		}
	}
}
